/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;
import util.J2meAppHelper;

/**
 *
 * @author Alexandre Walter Pretyman
 */
public abstract class ConfirmForm extends Form implements AppForm, CommandListener {
    private Command simCmd = new Command("Sim", 3, Command.OK );
    private Command naoCmd = new Command("Não", 4, Command.CANCEL );

    public void setNaoCmdAppFrm(AppForm naoCmdAppFrm) {
        this.naoCmdAppFrm = naoCmdAppFrm;
    }

    public void setSimCmdAppFrm(AppForm simCmdAppFrm) {
        this.simCmdAppFrm = simCmdAppFrm;
    }
    private AppForm simCmdAppFrm = null;
    private AppForm naoCmdAppFrm = null;


    
    public ConfirmForm()
    {
        super(":: Atenção ::");
        StringItem strItm = new StringItem("", "Atenção\nVocê está escolhendo uma operação\nqual não poderá desfazer\nDeseja continuar?");
        append(strItm);
        addCommand(simCmd);
        addCommand(naoCmd);
        setCommandListener(this);
        
    }

    public Displayable getDisplyable() {
        return this;
    }

    public void initialize(Object parameter) 
    {

    }

    public void commandAction(Command cmd, Displayable disp) {
        if (cmd == simCmd && disp == this)
        {
            task();
            J2meAppHelper.getInstance().changeForm(simCmdAppFrm);
        }
        else if (cmd == naoCmd && disp == this)
        {
           J2meAppHelper.getInstance().changeForm(naoCmdAppFrm);
        }
    }
    
    protected abstract void task();
    

    
    
    
    

}
